<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目产品报价方案</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">

var grid = null;
$(function () {
	initGrid();//grid
	  $("#searchBar").ligerForm();
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
});
	
  function clearBtn(){
	    $("#searchBar").ligerForm();
				var form = new liger.get("searchBar");
				form.setData({
					lsCntNo:"",
					paySchNo:""
				 });
		}
//初始化列表
function initGrid(){
	var params = {};
	$("#grid").ligerGrid({
    	url: '<%=path%>/project/prjprdpayschm/getLsDatePrjPrdPaySchMList.do',
    	method : 'get',
    	parms:params,
        columns: [
             { display: '合同编号', name: 'lsCntNo', minWidth: 150 ,align:'left',enabledSort:true},
             { display: '支付表号', name: 'paySchNo', minWidth: 200,align:'left',
                	 	render: function (rowdata, rowindex, value, column) { 
    	            		var h = '';
    	            		    h='<a href="javascript:detailBtn(';
    	                        h+="'"+rowdata.prjPrdDtlId+"',";
    	                        h+="'"+rowdata.id+"',";
    	                        h+="'"+rowdata.prjPrdId+"',";
    	                        h+="'"+rowdata.prjId+"'";
    	                        h+=')">'+value+'</a>'
    	                        return h;
    	            		},
                	  enabledSort:true},
             { display: '承租人名称', name: 'cstNm', minWidth: 80,align:'left',enabledSort:true}, 
             { display: '状态', name: 'prdStsCdNm', minWidth: 80,align:'left',enabledSort:true}, 	
             { display: '创建时间', name: 'crtTm', minWidth: 80,align:'left',render:renderDate,enabledSort:true}, 
             { display: '起租日', name: 'lsDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true}, 	
            /*  { display: '结清时间', name: 'stlDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true}, 	
             { display: '拖回时间', name: 'backDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true}, 	
             { display: '转正常时间', name: 'formDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true}, 	 */
             {
                display: '操作',
                isSort: false,
                width: 300,
                align:'center',
                isEllipsis: false,
                render: function (rowdata, rowindex, value){
                     var h="";
		              	  h+='<a class="sq-button-hasicon" href="javascript:changeLsDt(';
		                   h+="'"+rowdata.id+"',";
		                   h+="'"+rowdata.prjId+"',";
		                   h+="'"+rowdata.buOrgCd+"'";
		                   h+=')">修改起租日</a>';
		                   //修改结清时数据信息
		              	   h+='<a class="sq-button-hasicon" href="javascript:changePayStlData(';
		                   h+="'"+rowdata.id+"',";
		                   h+="'"+rowdata.prjPrdDtlId+"',";
		                   h+="'"+rowdata.prjId+"'";
		                   h+=')">修改结清相关数据</a>';
		              	return h;
                }
            }  
        ],
        pageSize:10,
        root:'rows',
        record:'total',
        hideLoadButton : true,
        width: '100%',
        height:'100%',
        heightDiff:-2,
        checkbox:true,
        allowUnSelectRow: true,
        alternatingRow: true,
        rownumbers:true,
        enabledEdit: false,
        fixedCellHeight: false,
        usePagerOnLessPagesize: true,
    });
	grid = liger.get("grid");
	grid.setHeight(300);
	
}
//格式化为人民币格式
function renderAmt(rowdata, rowindex, value) {
    var h="￥" + FormatMoney(value)
    return h;
}

//格式化时间
function renderDate(rowdata, index, value){
	var dateStr = "";
	if(null != value&&value!=''){
		var date = new Date(value);
		dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
	}
	return dateStr;
}

function changeLsDt(id,prjId,buOrgCd){
		$.ligerDialog.open({width: 700,
	    	   buttons: [{
	                text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', onclick: function(){
	                	changeSave(id,prjId,buOrgCd);
	                }
	            },
	            {
	                text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', onclick:function(){
	                	$.ligerDialog.hide();
	                }
	            }
	        ],
	        title: '修改起租日',
	        target: $("#changeLsDt")
	    });
	    var ligerForm = $("#changeLsDt_form").ligerForm({validate: true});
	    var form = new liger.get("changeLsDt_form");
		form.setData({
			lsDt:"",
			thdPayAmt:""
		 });
}

function changeSave(id,prjId,buOrgCd){
	$.ajax({
		type: 'post',
		dataType:'json',
		data:{
			id:id,
			prjId:prjId,
			buOrgCd:buOrgCd,
			lsDt:$("#lsDt").val(),
			thdPayAmt:$("#thdPayAmt").val()
		},
		url: '<%=path%>/project/prjprdpayschm/modifyPrjPaySchMLsDt.do',
		success:function(msg){
			if(msg.success == 1){
            	$.ligerDialog.hide();
            	top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
				 grid.reload();
			 }else{
				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
			 }
		}
	});
}

function detailBtn(prjPrdDtlId,id,prjPrdId,prjId){
	var editFlag = true;
	Add_navTab('tab_prj_quat_prps'+id,'查看支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+prjId+'&&id='+id+'&&prjPrdDtlId='+prjPrdDtlId+'&&prjPrdId='+prjPrdId+'&&detailFlag='+editFlag);
 }
function changePayStlData(id,prjPrdDtlId,prjId){
	var editFlag = true;
	Add_navTab('tab_prj_quat_prps'+id,'结清数据修改页面','<%=path%>/project/prjprdpayschm/toPayStlDataAddPage.do?id='+id+'&&dtlId='+prjPrdDtlId+'&&prjId='+prjId);
 }

function iframeResize () {
    if (parent.mainApp) {
        parent.mainApp.parentTab.onResize();
    };
}

	var callback = function () {
		var form = new liger.get("searchBar");
        var data = form.getData();
        for (name in data){
           grid.setParm(name,data[name]);
        };
	    grid.reload();
	};
	
	function dealZSChangeOurDataBtn(){
		 var url = '<%=path%>/project/prjquatprps/dealZSChangeOurData.do';
		    var wait_dialog;
		    $.ajax({
				type: 'post',
				dataType:'json',
				url: url,
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					 wait_dialog.close();
					 if(msg.success == 1){
						 $.ligerDialog.SQalert({content:"处理成功！", SQ_type: "success"});
					 }else{
						 $.ligerDialog.SQalert({content:"处理失败！", SQ_type: "error"});
					 }
				}
			});
	}
	
	function dealPFChangeOurDataBtn(){
        var insCodes = "浦发、众邦、华润、新邮储、新网、上海银行、中关村银行、三湘银行、宜宾银行、江西银行";
        $.ligerDialog.confirm("确认处理如下机构的转我司处理【"+insCodes+"】?",function(flag) {
            if (false == flag) return;
            var url = '<%=path%>/project/prjquatprps/dealPFChangeOurData.do';
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                url: url,
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: "处理成功！", SQ_type: "success"});
                    } else {
                        $.ligerDialog.SQalert({content: "处理失败！", SQ_type: "error"});
                    }
                }
            });
        })
	}
	
	function dealWSChangeOurDataBtn(){
        var insCodes = "网商、苏宁小贷、苏宁银行";
        $.ligerDialog.confirm("确认处理如下机构的转我司处理【"+insCodes+"】?",function(flag) {
            if (false == flag) return;
		    var url = '<%=path%>/project/prjquatprps/dealWSChangeOurData.do';
		    var wait_dialog;
		    $.ajax({
				type: 'post',
				dataType:'json',
				url: url,
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					 wait_dialog.close();
					 if(msg.success == 1){
						 $.ligerDialog.SQalert({content:"处理成功！", SQ_type: "success"});
					 }else{
						 $.ligerDialog.SQalert({content:"处理失败！", SQ_type: "error"});
					 }
				}
			});
        })
	}

	function modifyDealZGPayDtData(){
		 var url = '<%=path%>/project/prjquatprps/modifyDealZGPayDtData.do';
		    var wait_dialog;
		    $.ajax({
				type: 'post',
				dataType:'json',
				url: url,
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					 wait_dialog.close();
					 if(msg.success == 1){
						 $.ligerDialog.SQalert({content:"处理成功！", SQ_type: "success"});
					 }else{
						 $.ligerDialog.SQalert({content:"处理失败！", SQ_type: "error"});
					 }
				}
			});
	}
function modifyZYChangeOurData(){
    var insCodes = "浙银、江西金租、兴邦、三井、微众";
    $.ligerDialog.confirm("确认处理如下机构的转我司处理【"+insCodes+"】?",function(flag) {
        if (false == flag) return;
        var url = '<%=path%>/project/prjquatprps/dealZYChangeOurData.do';
        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: url,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    $.ligerDialog.SQalert({content: "处理成功！", SQ_type: "success"});
                } else {
                    $.ligerDialog.SQalert({content: "处理失败！", SQ_type: "error"});
                }
            }
        });
    })
}

/* 数据核查*/
function exportCheckData(){
    var params = {};
    var url = '<%=path%>/project/prjquatprps/exportCheckData.do';
    var wait_dialog;
    $.ajax({
        type: 'post',
        dataType:'json',
        url: url,
        data:params,
        beforeSend:function(){
            wait_dialog=$.ligerDialog.SQalert({content: '正在导出...',SQ_type: "waitting"});
        },
        success:function(msg){
            wait_dialog.close();
            if(msg.success == 1){
                var tempwindow= window.open("_blank");
                tempwindow.location=msg.data;
            }else{
                $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
            }
        }
    });
}

</script>

<body class="iframeBody">
	<div class="Wrapper">
        <div>
           <div id="pageInTab" class="pageInTab">
 <div class="searchArea">
    <form id="searchBar">
   <div class="fieldset1 clearFix">
            <div class="fieldBox col_33" >
                <div class="label">合同编号</div>
                <div class="field">
                    <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                </div>
            </div>
              <div class="fieldBox col_33" >
                <div class="label">支付表号</div>
                <div class="field">
                    <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="clearFix"></div>
   	<div class="btnsBox">
   			<span id="searchBtn"  class="sq-button sq-button-round">查询</span>
           <span id="clearBtn" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
        <!--
   	      <span id="dealZSChangeOurDataBtn"  onclick="dealZSChangeOurDataBtn()" class="sq-button sq-button-round">处理浙商转我司数据</span>
   	      -->
            <span id="dealPFHisIrrPctBtn"  onclick="dealPFChangeOurDataBtn()" title="浦发、众邦、华润、新邮储、新网、上海银行、中关村银行、三湘银行、宜宾银行、江西银行" class="sq-button sq-button-round">处理浦发租金贷类转我司数据</span>
          <span id="dealWSHisIrrPctBtn"  onclick="dealWSChangeOurDataBtn()" title="网商、苏宁小贷、苏宁银行" class="sq-button sq-button-round">处理网商类转我司数据</span>
        <span id="dealZYHisData"  onclick="modifyZYChangeOurData()" title="浙银、江西金租、兴邦、三井、微众" class="sq-button sq-button-round">处理浙银类转我司数据</span>
        <span id="dealZGPayDtBtn"  onclick="modifyDealZGPayDtData()" class="sq-button sq-button-round">修改还款日</span>
        <span id="exportCheckDataBtn"  onclick="exportCheckData()" class="sq-button sq-button-round">转我司数据核查</span>
 	</div>
</div>
</form>
</div>
<div id="grid" class="sq-grid"></div>
</div>
	</div>
		</div>
<div id="changeLsDt" style="display:none">
    <form id="changeLsDt_form">
        <div class="fieldset1 tabel_col tabel_col_s noBorder clearFix">
            <div class="fieldBox col_50">
                <div class="label">起租日</div>
                <div class="field">
                    <input name="lsDt" id="lsDt" type="text" class="ui-datepicker" validate="{required:true}" value="">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label">实际放款金额</div>
                <div class="field">
                    <input name="thdPayAmt" id="thdPayAmt" type="text" class="ui-textbox"  value="">
                </div>
            </div>
        </div>
        <div class="btnsBox">
            <span class="sq-button sq-button-hasicon Hide"><i class="sqBtnIco_10"></i>保存</span>
            <span class="sq-button sq-button-hasicon l-dialog-btn-cancel Hide"><i class="sqBtnIco_14"></i>取消</span>
        </div>
    </form>
</div>
		
</body>
</html>